package com.baway.biliclitent.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.baway.biliclitent.R;
import com.baway.biliclitent.model.LiveBean;
import com.baway.biliclitent.view.CircleImageView;
import com.baway.biliclitent.view.LoveLikeLayout;
import com.bumptech.glide.Glide;

/**
 * 1.类的用途：
 * 2.作者：${赵渊} on 2017/3/18 13:52
 */
public class LiveDetailsActivity extends AppCompatActivity{

    private CircleImageView user_pic;
    private TextView user_name;
    private TextView live_num;
    private LoveLikeLayout love_layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_live_details);
        initViews();
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
       if (actionBar != null) {
           setSupportActionBar(toolbar);
           actionBar.setDisplayHomeAsUpEnabled(true);
           actionBar.setHomeButtonEnabled(true);
        }
        //得到传过来的值
        Intent intent = getIntent();
        if(intent!=null){
            LiveBean.DataBean.PartitionsBean.LivesBeanX livesBean = (LiveBean.DataBean.PartitionsBean.LivesBeanX) intent.getSerializableExtra("live");
            Glide.with(getApplicationContext()).load(livesBean.getOwner().getFace()).into(user_pic);
            user_name.setText(livesBean.getOwner().getName());
            live_num.setText(livesBean.getOnline()+"");
            toolbar.setTitle(livesBean.getTitle());
        }
    }

    private void initViews() {
        user_pic = (CircleImageView) findViewById(R.id.user_pic);
        user_name = (TextView) findViewById(R.id.user_name);
        live_num = (TextView) findViewById(R.id.live_num);
        love_layout = (LoveLikeLayout) findViewById(R.id.love_layout);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId()==android.R.id.home){
            onBackPressed();
        }
        return super.onOptionsItemSelected(item);
    }
}
